<template>
  <div class="box">
    <div class="clearfix top">
      <p class="title">年龄比例</p>
      <p class="bg"></p>
    </div>

    <div class="charts" ref="echartsRef"></div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'

import * as echarts from 'echarts'
const echartsRef = ref()
onMounted(() => {
  const myCharts = echarts.init(echartsRef.value)
  myCharts.setOption({
    tooltip: {
      trigger: 'item'
    },
    legend: {
      top: 30,
      right: 30,
      orient:'vertical',
      textStyle:{
        color:'#fff',
        'font-size':14
      }
    },
    series: [
      {
        name: 'Access From',
        type: 'pie',
        center:['40%','50%'],
        radius: ['40%', '70%'],
        avoidLabelOverlap: false,
        itemStyle: {
          borderRadius: 10,
          borderColor: '#fff',
          borderWidth: 2
        },
        label: {
          show: true,
          position: 'inside',
          color:'#fff',
        },
       
        labelLine: {
          show: false
        },
        data: [
          { value: 1048, name: '财经' },
          { value: 735, name: '新闻' },
          { value: 580, name: '热点' },
          { value: 484, name: '直播' },
          { value: 300, name: '娱乐' }
        ]
      }
    ]
  })
})
</script>

<style scoped lang="scss">
.box {
  display: flex;
  flex-direction: column;
  background: #fff;
  background: url(../../images/dataScreen-main-cb.png) no-repeat;
  background-size: 100% 100%;
  overflow: hidden;
  .top {
    padding-top: 10px;
    font-size: 20px;
    margin: 0 20px;
    color: #fff;
    .title {
    }
    .bg {
      margin-top: 10px;
      width: 68px;
      height: 7px;
      background: url(../../images/dataScreen-title.png) no-repeat;
      background-size: 100% 100%;
    }
  }

  .charts {
    width: 100%;
    flex: 1;
  }
}
</style>
